﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows;
using System.Windows.Threading;


namespace LoggerLib
{
    public static class Logger
    {
        public static void Log(DispatcherUnhandledExceptionEventArgs e)
        {

            e.Handled = true;
            Form1 messageBox = new Form1(e);
            messageBox.Show();
            

            string pathLogEx = @"Logs\ExceptionLog.txt";
            if (!File.Exists(pathLogEx))
            {
                Directory.CreateDirectory("Logs");
                File.Create(pathLogEx);
            }
            File.AppendAllText(pathLogEx,
                DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + Environment.NewLine +
                "\tSource" + ":\t" + e.Exception.Source + Environment.NewLine +
                "\tMessage" + ":\t\t" + e.Exception.Message + Environment.NewLine +
                "\tInnerException" + ":\t\t" + e.Exception.InnerException + Environment.NewLine +
                "\tTargetSite" + ":\t\t" + e.Exception.TargetSite + Environment.NewLine +
                Environment.NewLine);

           
        }
    }
}
